<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<%@ include file="../common/top_css.jsp"%>
<script src="${pageContext.request.contextPath}/bootstrap/js/jquery.js"></script> <!-- jQuery -->
<script type="text/javascript">
	$(function(){
			$.ajax({
				url : "${pageContext.request.contextPath}/supplier/selectSupplierList.action",
				type : "POST",
				dataType : "json", 
				data : {},
				success : function(result, start, resp) {
					var str='';
					for ( var i = 0; i < result.length; i++) {
						str+='<tr><td>'+result[i].name+'</td><td>'+result[i].address+'</td><td>'+result[i].contact+'</td><td>'+result[i].tele+'</td><td>'+result[i].needsView+'</td><td><button class="btn btn-xs btn-warning" onclick="'+"javascript:location.href='${pageContext.request.contextPath}/supplier/selectSupplierById.action?uuid="+result[i].uuid+"'"+'"><i class="icon-pencil"></i></button><button class="btn btn-xs btn-danger" onclick="'+"javascript:location.href='${pageContext.request.contextPath}/supplier/deleteSupplier.action?uuid="+result[i].uuid+"'"+'"><i class="icon-remove"></i></button></td></tr>';
					}
					$("#tables").append(str);
				}
			});
		
			$("#search").click(function(){
				var name=$("input[name='name']").val();
				var contact=$("input[name='contact']").val();
				var tele=$("input[name='tele']").val();
				var needs=$("select[name='needs']").val();
				$.ajax({
					url : "${pageContext.request.contextPath}/supplier/selectSupplierList.action",
					type : "POST",
					dataType : "json", 
					data : {"name":name,"contact":contact,"tele":tele,"needs":needs},
					success : function(result, start, resp) {
						var str='';
						for ( var i = 0; i < result.length; i++) {
							str+='<tr><td>'+result[i].name+'</td><td>'+result[i].address+'</td><td>'+result[i].contact+'</td><td>'+result[i].tele+'</td><td>'+result[i].needsView+'</td><td><button class="btn btn-xs btn-warning" onclick="'+"javascript:location.href='${pageContext.request.contextPath}/supplier/selectSupplierById.action?uuid="+result[i].uuid+"'"+'"><i class="icon-pencil"></i></button><button class="btn btn-xs btn-danger" onclick="'+"javascript:location.href='${pageContext.request.contextPath}/supplier/deleteSupplier.action?uuid="+result[i].uuid+"'"+'"><i class="icon-remove"></i></button></td></tr>';
						}
						$("#tdAdd").empty();
						$("#tables").append(str);
					}
				});
			});
	});
	

</script>

</head>

<body>
	<div class="navbar navbar-fixed-top bs-docs-nav" role="banner">
		<div class="conjtainer">
  			<%@ include file="../common/top_nav.jsp" %>
		</div>
	</div>

	<%@ include file="../common/top.jsp" %>
	<div class="content">
		<%@ include file="../common/left.jsp" %>
		<div class="mainbar">
		<%@ include file="../common/page-head.jsp" %>
			<div class="matter">
				<div class="container">
				<!-- 内容开始 -->
					<!-- 表单 -->
					<div class="widget wgreen">
		                <div class="widget-head">
		                  <div class="pull-left">搜索</div>
		                  <div class="widget-icons pull-right">
		                    <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a> 
		                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
		                  </div>
		                  <div class="clearfix"></div>
		                </div>
		                <div class="widget-content">
		                  <div class="padd">
		                    <!-- Form starts.  -->
		                     <form class="form-horizontal" role="form">
		                              
		                                <div class="form-group">
		                                  <label class="col-lg-2 control-label">供应商</label>
		                                  <div class="col-lg-4">
		                                    <input class="form-control" name="name" placeholder="供应商" type="text">
		                                  </div>
		                                  <label class="col-lg-2 control-label">联系人</label>
		                                  <div class="col-lg-4">
		                                    <input class="form-control" name="contact" placeholder="联系人" type="text">
		                                  </div>
		                                </div>
		                                <div class="form-group">
		                                  <label class="col-lg-2 control-label">电话</label>
		                                  <div class="col-lg-4">
		                                    <input class="form-control" name="tele" placeholder="电话" type="text">
		                                  </div>
		                                  <label class="col-lg-2 control-label">提货方式</label>
		                                  <div class="col-lg-4">
		                                    <select class="form-control" name="needs">
		                                      <option value="">--请选择--</option>
		                                      <option value="1">送货</option>
		                                      <option value="2">自提</option>
		                                    </select>
		                                  </div>
		                                </div>     
		                                <hr>
		                                <div class="form-group">
		                                  <div class="col-lg-offset-1 col-lg-9">
		                                    <button type="button" id="search" class="btn btn-success">Search</button>
		                                    <button type="button" id="insert" class="btn btn-info" onclick="javascript:location.href='${pageContext.request.contextPath}/jsp/goods/supplieradd.jsp'">Add</button>
		                                  </div>
		                                </div>
		                              </form>
		                  </div>
		                </div>
		                  <div class="widget-foot">
		                    <!-- Footer goes here -->
		                  </div>
		              </div>	
					<!-- 表格 -->
					<div class="widget">
		                <div class="widget-head">
		                  <div class="pull-left">供应商列表</div>
		                  <div class="widget-icons pull-right">
		                    <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a> 
		                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
		                  </div>  
		                  <div class="clearfix"></div>
		                </div>
		                <div class="widget-content">
			                <table class="table table-striped table-bordered table-hover" id="tables">
			                      <thead>
			                        <tr>
			                          <th>供应商</th>
			                          <th>地址</th>
			                          <th>联系人</th>
			                          <th>电话</th>
			                          <th>送货方式</th>
			                          <th>Control</th>
			                        </tr>
			                      </thead>
			                      <tbody id="tdAdd">
			                      </tbody>
			                    </table>
		                    <div class="widget-foot">
		                        <ul class="pagination pull-right">
		                          <li><a href="#">Prev</a></li>
		                          <li><a href="#">1</a></li>
		                          <li><a href="#">2</a></li>
		                          <li><a href="#">3</a></li>
		                          <li><a href="#">4</a></li>
		                          <li><a href="#">Next</a></li>
		                        </ul>
		                      <div class="clearfix"></div> 
		                    </div>
		
		                </div>
		
	                </div>
				
				
				<!-- 内容结束 -->
				</div>
			</div>
		</div>
	</div>
	<%@ include file="../common/footer.jsp" %>
 	<%@ include file="../common/footer_js.jsp" %>
</body>
</html>
